package com.glsc.ngateway.common.base.domain.mysql.gateway.oaflow;


import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.time.LocalDateTime;


@Entity
@Table(name = "t_oa_flow_message_table")
public class TOaFlowMessageTable {

    // 自增ID
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Integer id;

    @Column(name = "work_flow_name")
    private String workFlowName;

    @Column(name = "work_flow_id")
    private String workFlowId;

    @Column(name = "request_id")
    private String requestId;

    //unnix 时间
    @Column(name = "send_time")
    private Long sendTime;

    @Column(name = "description")
    private String description;

    @Column(name = "dt_op_time", columnDefinition = "datetime comment '操作时间'")
    @org.hibernate.annotations.UpdateTimestamp
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    protected LocalDateTime opTime;


    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getWorkFlowName() {
        return workFlowName;
    }

    public void setWorkFlowName(String workFlowName) {
        this.workFlowName = workFlowName;
    }

    public String getWorkFlowId() {
        return workFlowId;
    }

    public void setWorkFlowId(String workFlowId) {
        this.workFlowId = workFlowId;
    }

    public String getRequestId() {
        return requestId;
    }

    public void setRequestId(String requestId) {
        this.requestId = requestId;
    }

    public Long getSendTime() {
        return sendTime;
    }

    public void setSendTime(Long sendTime) {
        this.sendTime = sendTime;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public LocalDateTime getOpTime() {
        return opTime;
    }

    public void setOpTime(LocalDateTime opTime) {
        this.opTime = opTime;
    }


    public TOaFlowMessageTable() {
    }

    public TOaFlowMessageTable(String workFlowId, String workFlowName, String requestId, String description) {
        this.workFlowId = workFlowId;
        this.workFlowName = workFlowName;
        this.requestId = requestId;
        this.description = description;
        this.sendTime = System.currentTimeMillis() / 1000L;
    }

    @Override
    public String toString() {
        return "TOaFlowMessageTable{" +
                "id=" + id +
                ", workFlowName='" + workFlowName + '\'' +
                ", workFlowId='" + workFlowId + '\'' +
                ", requestId='" + requestId + '\'' +
                ", sendTime=" + sendTime +
                ", description='" + description + '\'' +
                ", opTime=" + opTime +
                '}';
    }
}
